<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 去重
        let arr = [12, 45, 45, 444, 5, 44, 45, 5]
        arr = new Set([...arr])
        // for (const iterator of arr.entries()) {
        //     console.log(iterator);
        // }
        // 可迭代对象使用
        //  使用entries获取可迭代对象,可迭代对象每进行一次next就会返回一个对象
        let ent = arr.entries()

        // for of 内部多次调用next
        console.log(ent.next());
        console.log(ent.next());
        console.log(ent.next());
        arr = Array.from(arr)
        console.log(arr);

        // 使用生成器

        let obj = {
            fun: function* () {
                yield 1
                yield 2
                yield 3
            }
        }
        let ents = obj.fun()
        console.log(ents.next());
        console.log(ents.next());
        console.log(ents.next());
    </script>
</body>

</html>